package com.xuecheng.content.controller;

import com.xuecheng.api.content.CourseAuditApi;
import com.xuecheng.api.content.model.qo.QueryCourseBaseModel;
import com.xuecheng.api.content.model.vo.CourseAuditVO;
import com.xuecheng.common.domain.page.PageRequestParams;
import com.xuecheng.common.domain.page.PageVO;
import com.xuecheng.common.util.SecurityUtil;
import com.xuecheng.content.service.CourseBaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class CourseAuditController implements CourseAuditApi {

    // 运营平台标识--可以查询所哟教学机构的数据

    @Autowired
    private CourseBaseService courseBaseService;

    //平台查看所有机构的课程
    @PostMapping("m/course/list")
    public PageVO queryCourseList(PageRequestParams params, @RequestBody QueryCourseBaseModel model) {
        //long platform=1;
        //平台只查看已提交的
        //model.setAuditStatus(CourseAuditEnum.AUDIT_COMMIT_STATUS.getCode());
        model.setName("平台");
        Long companyId = SecurityUtil.getCompanyId();
        PageVO pageVO = courseBaseService.queryCourseList(params,model,companyId);
        return pageVO;
    }

    //平台审核课程
    @PostMapping("m/courseReview/approve")
    public void approveCourse(@RequestBody CourseAuditVO auditVO) {
        courseBaseService.approve(auditVO);

    }
}